<template>
	<div>
		<mu-list>
		    <mu-list-item :title="lb.LBMC" disableRipple  toggleNested v-for="(lb,index) in mainData">
			    <mu-icon slot="left" color="orange500" value="inbox"/>
			    <mu-list-item slot="nested"  disableRipple v-for="(xx,oIndex) in lb.xxList">
			    	<mu-avatar slot="left" color="white" backgroundColor="blue500">{{xx.XXMC}}</mu-avatar>
			    	<div style="padding-right:42px">
			        <div @click="tagClick(bq,lb,xx)" class="zss_bq" v-bind:class="{disable:disabled,zss_djbs:bq.xz}" v-for="(bq ,tIndex) in xx.bqList">{{bq.BQMC}}</div>		
			        </div>
			    </mu-list-item>	 
			</mu-list-item>
	    </mu-list>
	</div>
</template>
<script>
import axios from 'axios'
export default {
	props:{
		disabled:{
			Object
		},
    	nrbm:{
    		type: String
    	}
    	,khdxbh:{
    		type: String
    	}
    	,khdxxm:{
 			type: String
    	}
    	,lb:{
    		type: String
    	},
		userIdentity:{
			type:String
		}

	},data(){
		return{
			mainData:[]
		}
	},
	mounted(){
		this.loadkhsj();
	},methods:{
		tagClick(bq,lb,xx){//选中考勤标签
			if(!this.disabled){
				let that=this;
				bq.xz=!bq.xz;
				xx.xz=true;
				lb.xxList.filter(function(x){
					if(x.XXBH!=xx.XXBH){
						x.xz=false;
						x.bqList.filter(function(b){
							b.xz=false;
						})
					}
				});
			}
		},
		loadkhsj(){//加载考勤数据
			//设置成已考勤
			//this.xs.kh=true
			let that = this;
			axios.get('/gleenSoft-base/jxkh/jspx/pxbqlist', {
              params: {
                NRBM : that.nrbm,
                KHDXBH : that.khdxbh,
                LB:that.lb
              }
            }).then(function (response) {
              let sb=response.data.result;
              sb.filter(function(lb){
	              lb.xxList.filter(function(xx){
	              	xx.xz=false;
	                xx.bqList.filter(function(bq){
	                	if(bq.BQZT>0){
	                		xx.xz=true;
	                		bq.xz=true;
	                	}else{
	                		bq.xz=false;
	                	}
	              	});
	              });
	            });
              that.mainData=sb;
          })
          .catch(function (error) {
            console.log(error);
          });
		},submit(){	//提交选择的标签
			let that=this;
			let submitData={
	          NRBM:that.nrbm,
	          KHDXBH:that.khdxbh,
	          KHDXXM:that.khdxxm,
	          USERIDENTITY:that.userIdentity.toUpperCase(),
	          PJDA:[]
	        };
	        this.mainData.filter(function(l){
	          let xzlb={"LBBH":l.LBBH,XX:[]}
	          submitData.PJDA.push(xzlb);
	          l.xxList.filter(function(x){
	            if(x.xz){
	              let xzxx={
	                XXBH:x.XXBH,
	                XXBM:x.XXBM,
	                XXMC:x.XXMC,
	                BQ:[]
	              }
	              xzlb.XX.push(xzxx);
	              
	              x.bqList.filter(function(b){
	                if(b.xz){
	                  xzxx.BQ.push({BQBH:b.BQBH,BQBM:b.BQBM,BQMC:b.BQMC});
	                }
	              })
	            }
	          })
	        });
        	axios.post('/gleenSoft-base/jxkh/jspx/save',submitData).then(function (response) {
            	console.log(response);
          	}).catch(function (error) {
            	console.log(error);
          	});
		}
	},watch:{
		khdxbh(){
			console.info(111)
			this.loadkhsj();
		},
		nrbm(){
			this.loadkhsj();	
		}
	}
}
</script>
<style>
.zss_bq{border:1px solid #ffa809;color: black;display: inline-block;padding: 5px; border-radius:3px;margin:3px;}
.zss_jb{
    color: white;
    display: inline-block;
    padding: 5px;
    border-radius: 16px;
    margin: 3px;
    width: 32px;
    height: 32px;
    text-align: center;
    background-color: #28cdff;
 }
.zss_djbs{background: #ffa809;color: white;}
.disable{
	border-color: #bdbbb7;
	background-color: #dadada;
}
.modal-footer{padding:5px}
.p_class{    
		text-align: center;
	    line-height: 24px;
	    background: #eee;
	    border-radius: 12px;
	    margin: 8px 0;
	    color: #6d6d6d;
	    font-size: 16px;
	    }
[v-cloak] {
	    visibility: hidden;
	}
.zss_abcd{padding:10px 20px;color: #676767;background: none;}
.pjbtnbg{
	background-color:#c7c7c7;
}
</style>